﻿@model List<HANS_WeChat.Base.Model.WeModel.CommonMenu.WeChatCommonMunu>
@{
    ViewBag.Title = "微信公众号菜单列表";
}
@section Styles{
    <style type="text/css">
        .x_title h2 small {
            display: inline;
        }
    </style>
}
@section Scripts{
    <script type="text/javascript">
        //不需要排序（用户自己排序去）
        //$(function () {
        //    $('#permissionList').nestable({
        //        maxDepth: 5
        //    }).on('change', function (e) {
        //        console.log($(e.target).nestable('serialize'));
        //    });

        //    window.getConfirmAttachData = function () {
        //        return { "orderInfo": JSON.stringify($("#permissionList").nestable('serialize')) };
        //    }


        //    Messagetoastr.TypeShow.info("提示：请小心操作本页面");
        //})
    </script>
}
@helper OrderList(List<HANS_WeChat.Base.Model.WeModel.CommonMenu.WeChatCommonMunu> WeChatCommonMunus)
{
    <ol class="dd-list">
        @foreach (var item in WeChatCommonMunus)
        {
            <li class="dd-item dd3-item" data-id="@item.Id">
                <div class="dd-handle dd3-handle"></div>
                <div class="dd3-content">
                    @(item.Menuname)
                    &nbsp;&nbsp;&nbsp;
                    @(item.Menutype??"顶级")
                    <div id="datatable_filter" class="dataTables_filter">
                        <a href="@Url.Action("UpdateCommonMenu", "WeChatMenu",new { id=item.Id ,area="HANSWeChat"})" class="btn btn-xs btn-success"><i class="fa fa-edit"></i>修改</a>
                        <a data-confirmed-text="确认删除（如果是主菜单，子菜单一并删除）？"
                           data-confirmed-button="删除"
                           data-confirmed-cancel-button="取消"
                           data-confirmed-button-class="btn-danger"
                           data-confirmed-url="@Url.Action("DeleteCommonMenu",  "WeChatMenu",new { id=item.Id ,area="HANSWeChat"})"
                           class="btn btn-danger btn-xs js-confirm-submit">
                            <!--js-confirm-submit js post 提交-->
                            <i class="fa fa-trash-o"></i>删除
                        </a>
                    </div>

                </div>
                @{
                  
                    if (item.WeChatCommonMunuChild.Count > 0)
                    {
                        @OrderList(item.WeChatCommonMunuChild);
                    }

                }

            </li>
                    }
    </ol>
}
<div class="x_panel">
    <!--beginHead-->
    <div class="x_title">
        <h2>微信公众号菜单列表<small>HANS</small></h2>
        <ul class="nav navbar-right panel_toolbox">
            <li>
                <a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
            </li>
        </ul>
        <div class="clearfix"></div>
    </div>
    <!--endHead-->
    <div class="x_content">
        <div id="datatable_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer form">
            <!--beginSearch-->
            <form>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="dataTables_length" id="datatable_length">
                            <a href="@Url.Action("CreateCommonMenu","WeChatMenu",new { area="HANSWeChat"})" class="btn btn-success">
                                <i class="fa fa-plus"></i>添加
                            </a>
                            <a data-confirmed-text="确定上传到微信公众号？"
                               data-confirmed-button="上传"
                               data-confirmed-cancel-button="取消"
                               data-confirmed-button-class="btn-success"
                               data-confirmed-url="@Url.Action("CommonMenuCloudUpload",  "WeChatMenu",new { area="HANSWeChat"})"
                               class="btn btn-info js-confirm-submit">
                                <!--js-confirm-submit js post 提交-->
                                <i class=" fa fa-cloud-upload"></i>上传到微信
                            </a>
                            <a data-confirmed-text="确定同步到本地？如果同步到本地，之前本地数据将删除掉？"
                               data-confirmed-button="同步"
                               data-confirmed-cancel-button="取消"
                               data-confirmed-button-class="btn-success"
                               data-confirmed-url="@Url.Action("CommonMenuCloudDownload",  "WeChatMenu",new { area="HANSWeChat"})"
                               class="btn btn-info js-confirm-submit">
                                <!--js-confirm-submit js post 提交-->
                                <i class="fa fa-cloud-download"></i>同步到本地
                            </a>
                        </div>
                    </div>
                </div>
            </form>
            <!--endSearch-->
            <!--begiContent-->
            <div class="row">
                <div id="permissionList" class="col-sm-12 ">
                    @OrderList(Model)
                </div>
            </div>
            <!--endContent-->
        </div>
    </div>
</div>